#include<iostream>
#include<vector>
#include<queue>
using namespace std;

class Solution {
public:
    vector<int> smallestK(vector<int>& arr, int k) {
        priority_queue<int,vector<int>,less<int>> queue_;
        for (int i = 0; i < arr.size(); ++i) {
            queue_.push(arr[i]);
            while (queue_.size() > k) queue_.pop();
        }
        vector<int> res;
        while (!queue_.empty()) {
            res.push_back(queue_.top());
            queue_.pop();
        }
        return res;
    }
};